package com.vrv.netmgr.alarm.detail;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.TextView;

import com.vrv.common.GlobalConstants;
import com.vrv.common.util.StringUtils;
import com.vrv.netmgr.R;
import com.vrv.netmgr.vo.ErrorMessage;

/**
 * @Description 注册资产查询策略详细信息
 * @author yangzijian
 * @date
 *
 */
public class DetailEquipmentChangedActivity extends Activity {

    private final String TAG = getClass().getSimpleName();
    private static final boolean DEBUG = true && GlobalConstants.DEBUG;
    private ErrorMessage info;

    public void onCreate(Bundle savedInstanceState) {
        if (DEBUG)
            Log.v(TAG, "onCreate()");

        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.detail_equipmentchange);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.common_title);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        //
        initViews();
        setTitle();
    }

    //
    public void initViews() {
        if (DEBUG)
            Log.v(TAG, "initViews()");
        //
        TextView eqmc_deptName = (TextView) findViewById(R.id.eqmc_deptName);
        TextView eqmc_officeName = (TextView) findViewById(R.id.eqmc_officeName);
        TextView eqmc_userName = (TextView) findViewById(R.id.eqmc_userName);
        TextView eqmc_tel = (TextView) findViewById(R.id.eqmc_tel);
        TextView eqmc_ipaddres = (TextView) findViewById(R.id.eqmc_ipaddres);
        // TextView eqmc_deviceName = (TextView)
        // findViewById(R.id.eqmc_deviceName);
        TextView eqmc_ipaddres1 = (TextView) findViewById(R.id.eqmc_ipaddres1);
        TextView eqmc_errorMsg = (TextView) findViewById(R.id.eqmc_errorMsg);
        TextView eqmc_sysUserName = (TextView) findViewById(R.id.eqmc_sysUserName);
        TextView eqmc_errorTime = (TextView) findViewById(R.id.eqmc_errorTime);
        TextView eqmc_macAddress = (TextView) findViewById(R.id.eqmc_macAddress);
        TextView eqmc_lookFlag = (TextView) findViewById(R.id.eqmc_lookFlag);
        //
        info = (ErrorMessage) getIntent().getSerializableExtra("info");
        //
        eqmc_deptName.setText(info.getEqmc_deptName());
        eqmc_officeName.setText(info.getEqmc_officeName());
        eqmc_userName.setText(info.getEqmc_userName());
        eqmc_tel.setText(info.getEqmc_tel());
        eqmc_ipaddres.setText(info.getEqmc_ipaddres());
        // eqmc_deviceName.setText(info.getEqmc_deviceName());
        eqmc_ipaddres1.setText(info.getEqmc_ipaddres1());
        eqmc_errorMsg.setText(info.getEqmc_errorMsg());
        eqmc_sysUserName.setText(info.getEqmc_sysUserName());
        eqmc_errorTime.setText(info.getEqmc_errorTime());
        eqmc_macAddress.setText(info.getEqmc_macAddress());
        if (StringUtils.isNotBlank(info.getEqmc_lookFlag()) && Integer.parseInt(info.getEqmc_lookFlag()) == 1) {
            eqmc_lookFlag.setText("已查看");
        } else {
            eqmc_lookFlag.setText("未查看");
        }

    }

    public void setTitle() {
        if (DEBUG)
            Log.v(TAG, "setTitle()");

        TextView title = (TextView) findViewById(R.id.title_text);
        title.setText("设备变化查询" + "[" + info.getEqmc_ipaddres() + "]");

        /**
         * 返回按钮
         */
        ImageButton backBtn = (ImageButton) findViewById(R.id.backBtn);
        backBtn.setVisibility(View.VISIBLE);
        backBtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    public void onBackPressed() {
        if (DEBUG)
            Log.v(TAG, "onBackPressed()");

        finish();
        overridePendingTransition(R.anim.push_right_out, R.anim.push_right_in);
        super.onBackPressed();
    }
}
